<?php
function reverseGeocode($latitude, $longitude){
if($latitude != '0' &&  $longitude!= '0'){
    $json = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?latlng='.$latitude.','.$longitude.'&sensor=false');
    $decodedJson = json_decode($json);
if ($decodedJson->status == 'OK') {
    return $decodedJson->results[4]->formatted_address; 
}
else {
    return 'Location not available';
}
}
else {
    return 'Location not available';
}
}
?>
